Skip to content

feat(introspection): add typed machine graph metadata#8

Merged
eboody merged 5 commits intomainfrom
feat/machine-introspection
Mar 22, 2026
Merged

feat(introspection): add typed machine graph metadata#8
eboody merged 5 commits intomainfrom
feat/machine-introspection

Conversation

@eboody
Copy link
Owner

@eboody eboody commented Mar 22, 2026

Summary

Add first-class machine introspection generated from the Statum machine definition itself.

This lets downstream crates use the machine definition as both:

  • the source of truth for compile-time legality
  • the source of truth for inspectable machine structure

What Changed

  • add typed introspection surfaces in statum-core
    • MachineIntrospection
    • MachineStateIdentity
    • MachineGraph and descriptor/query types
  • generate per-machine StateId, TransitionId, and static GRAPH metadata from #[machine]
  • collect exact transition sites, including branch alternatives from supported wrapper returns
  • add typed runtime transition recording and runtime-to-static join helpers
  • add an optional typed presentation metadata overlay keyed by generated ids
  • validate secondary transition targets during macro expansion
  • add integration and trybuild coverage for introspection, exact target sets, and runtime joins
  • document the optional future plan for attribute-based presentation sugar
  • bump crate versions to 0.6.6

Validation

  • cargo test --workspace
  • cargo test --offline -p statum-macros --test macro_errors
  • cargo test --offline -p macro_registry -p statum
  • cargo test --offline -p statum-core

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b8b22edb89

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +43 to +46
let mut sites = Vec::new();
for entry in &analysis.impls {
if !entry.attrs.iter().any(|attr| attr == "transition") {
continue;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Derive GRAPH from cfg-pruned transition items

collect_transition_sites is walking the raw parsed file here, so the new introspection graph is based on every #[transition] impl that appears in source rather than the impls/methods that actually survive #[cfg] and macro expansion. In a feature-gated machine, disabled transitions still get TransitionIds (and mutually exclusive variants can even collide and fail the build), while macro_rules!/include!-generated transitions never appear in GRAPH at all. That makes the new “exact transition-site” metadata incorrect whenever the transition set depends on build configuration or generated code.

Useful? React with 👍 / 👎.

@eboody eboody force-pushed the feat/machine-introspection branch from b8b22ed to fd93e5c Compare March 22, 2026 11:45
@eboody eboody merged commit ba09dd8 into main Mar 22, 2026
7 checks passed
@eboody eboody deleted the feat/machine-introspection branch March 22, 2026 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant